<?php
class p1_vote extends BaseModel implements Retrievable {

	var $event;
	var $user; // peak user
	var $calculated;
	
	// pts
	var $distance;	// - ranking: 1-10 points
	var $time_to_complete;	// - ranking: 1-10 points
	var $terrain; // - ranking: 1-8 points
	var $climate; // - ranking: 1-5 points
	var $factor; // - ranking: 1-5 points
	var $support; // - ranking: 1-4
	
    public function p1_vote($values) {
        parent::__construct($values);
    }

    public function validate() {
        $errors = Array();
		return (count($errors) === 0 ? true : $errors);
    }

    public static function get($id, $primaryKey='id') {
        return parent::get($id, __CLASS__, $primaryKey);
    }
    
    public static function getAll($searchArray=Array(), $sortArray=Array()) {
        return parent::getAll($searchArray, $sortArray, __CLASS__);
    }
    
    public function isAlreadyDone() {
    	$vote = p1_vote::getAll(array("event"=>$this->event, "user"=>$this->user, "calculated"=>"0"));
    	return !empty($vote);
    }
    
}
?>